﻿local Calendar = getRealTime()
local root = getRootElement()

function loadScript()
	setTimer(updateTime, 1000, 0)
end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), loadScript )

function updateTime()
	local Now = getRealTime()
	if Now.minute ~= Calendar.minute then triggerEvent ("onMinutePass", root, Now.minute) end
	if Now.hour ~= Calendar.hour then triggerEvent ("onHourPass", root, Now.hour) end
	if Now.monthday ~= Calendar.monthday then triggerEvent ("onMonthdayPass", root, Now.monthday) end
	if Now.month ~= Calendar.month then triggerEvent ("onMonthPass", root, Now.month) end
	if Now.year ~= Calendar.year then triggerEvent ("onYearPass", root, Now.year) end
	if Now.weekday ~= Calendar.weekday then triggerEvent ("onWeekdayPass", root, Now.weekday) end
	Calendar = Now
end


